﻿ 
using NBHF.Common;
using NBHF.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NBHF.BusinessService
{
    public sealed class IntergrationService
    {
        /// <summary>
        /// 易港通提箱补录信息查询
        /// </summary> 
        public static FindYGTCtnoutResultModel FindYGTCtnout(
            FindYGTCtnoutModel obj)
        {
            //AppUserLoginModel obj = new AppUserLoginModel();
            //obj.phone = phone;
            //obj.passwd = pwd;

            string ip = ConfigurationManager.AppSettings["url"];

            string url = $"{ip}/WisdomWebAPI/Intergration/FindYGTCtnout";

            string json = JsonConvert.SerializeObject(obj);


            try
            {
                json = HttpHelper.HttpPost(url, json);

                FindYGTCtnoutResultModel resultobj = (FindYGTCtnoutResultModel)JsonConvert.DeserializeObject<FindYGTCtnoutResultModel>(json);
                if (resultobj.code != "0")
                    throw new Exception(resultobj.message);

                return resultobj;
            }
            catch (Exception ex)
            {
                FindYGTCtnoutResultModel resultobj = new FindYGTCtnoutResultModel();
                resultobj.code = "99";
                resultobj.message = ex.Message;
                return resultobj;
            }
        }




        /// <summary>
        /// 易港通提箱补录
        /// </summary> 
        public static ResultModel YGTCtnoutSend(
           YGTCtnoutSendModel obj
            )
        { 
            string ip = ConfigurationManager.AppSettings["url"];

            string url = $"{ip}/WisdomWebAPI/Intergration/YGTCtnoutSend";

            string json = JsonConvert.SerializeObject(obj);

            try
            {
                json = HttpHelper.HttpPost(url, json);

                ResultModel resultobj = (ResultModel)JsonConvert.DeserializeObject<ResultModel>(json);
                if (resultobj.code != "0")
                    throw new Exception(resultobj.message);

                return resultobj;
            }
            catch (Exception ex)
            {
                ResultModel resultobj = new ResultModel();
                resultobj.code = "99";
                resultobj.message = ex.Message;
                return resultobj;
            }
        }





        /// <summary>
        /// 宁波换单查询（网站查询）
        /// </summary> 
        public static FindOnlineChangeBillForWebQueryResultModel FindOnlineChangeBillForWebQuery(
            FindOnlineChangeBillForWebQueryModel obj)
        {
            //AppUserLoginModel obj = new AppUserLoginModel();
            //obj.phone = phone;
            //obj.passwd = pwd;

            string ip = ConfigurationManager.AppSettings["url"];

            string url = $"{ip}/WisdomWebAPI/Intergration/FindOnlineChangeBillForWebQuery";

            string json = JsonConvert.SerializeObject(obj);


            try
            {
                json = HttpHelper.HttpPost(url, json);

                FindOnlineChangeBillForWebQueryResultModel resultobj = (FindOnlineChangeBillForWebQueryResultModel)JsonConvert.DeserializeObject<FindOnlineChangeBillForWebQueryResultModel>(json);
                if (resultobj.code != "0")
                    throw new Exception(resultobj.message);

                return resultobj;
            }
            catch (Exception ex)
            {
                FindOnlineChangeBillForWebQueryResultModel resultobj = new FindOnlineChangeBillForWebQueryResultModel();
                resultobj.code = "99";
                resultobj.message = ex.Message;
                return resultobj;
            }
        }
    }
}
